1. Field of the Invention
The invention relates to managing memory, and in particular to providing a data storage system for an application to use in accessing data.
2. Background Information
Document data is increasingly being stored and/or processed in a structured format using a data structure standard. In particular, data structure standards are used to provide a set of definitions that can be used to separate data content from a particular presentation. In this manner, the content can be quickly accessed and re-rendered in a different context. It has previously been recognized that by separating content from presentation it would be possible to share data on a platform-independent basis. One such early effort was the Electronic Data Interchange (“EDI”). Similarly, the Hypertext Markup Language (“HTML”), which has enjoyed widespread acceptance over the World Wide Web, represents another effort to normalize document data structures for facilitating the sharing of data between different computer systems.
While many data structure standards have been developed, one exemplary standard which has gained widespread recognition is the Extensible Markup Language (“XML”). XML, like HTML, evolved from the Standard Generalized Markup Language (“SGML”). XML is a document-based organizational standard that provides a set of rules for defining descriptions of structure and content in a document. XML uses tags that are similar to HTML tags, except that HTML tags provide a way of formatting information, while XML tags only organize and describe the data itself. That being the case, it is typically the case that XML documents must be parsed using a processing algorithm, as must XHTML and SGML documents.
Regardless of the data structure standard in use, there are two dominant approaches to navigating document data. The first type of navigation method, or parser, reads the document and transforms the data into its tree-structured equivalent. The most common example of this is the Document Object Model (“DOM”), which is based on the notion of using nodes to navigate a document. DOM, and other tree-based parsers, enable application programs to navigate and manipulate document data by loading and storing the entire document in this tree structure. However, this approach suffers from the fact that it is a strong consumer of memory resources. A DOM version of a document can easily consume two to three times as much memory as the original document would have. This can have a significant impact on applications which run in memory-poor environments, such as would be the case with embedded system applications.
The second approach to parsing document data is to analyze the document as a stream of text, rather than as a tree. In particular, as the various components of a document are encountered, the parser raises events (such as start and end elements), and reports such events back to the application program. A common example of an event-based parser is the Simple API for XML (“SAX”), which reports events to the application program using callbacks, which cause the application program to implement event handlers for the different types of events. While the event-based parser of a document requires much less memory than its DOM version would, event-based parsers can only process the current node and those nodes that are younger siblings or children of the current node. Moreover, the application program will have no control over the navigation through the document data.
Accordingly there is a need in the art for a system and method of managing memory which does not suffer from the aforementioned drawbacks.